<?php /* SVN: $Id: admin_index.ctp 69575 2011-10-25 05:50:05Z sakthivel_135at10 $ */ ?>
	<?php 
		if(!empty($this->request->params['isAjax'])):
			echo $this->element('flash_message');
		endif;
	?>

	<div  class="clearfix">
         <ul class="filter-list-block clearfix">
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Pending) { echo 'class="active"';} ?>><span class="green-block" title="<?php echo __l('Pending'); ?>"><?php echo $this->Html->link($this->Html->cInt($pending,false).'<span>' .__l('Pending'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => ConstWithdrawalStatus::Pending), array('escape' => false));?></span> </li>
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Approved) { echo 'class="active"';} ?>><span class="red-block" title="<?php echo __l('Under Process'); ?>"><?php echo $this->Html->link($this->Html->cInt($approved,false).'<span>' .__l('Under Process'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => ConstWithdrawalStatus::Approved), array('escape' => false));?></span> </li>
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Rejected) { echo 'class="active"';} ?>><span class="blue-block" title="<?php echo __l('Rejected'); ?>"><?php echo $this->Html->link($this->Html->cInt($rejected,false).'<span>' .__l('Rejected'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => ConstWithdrawalStatus::Rejected), array('escape' => false));?></span> </li>
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Success) { echo 'class="active"';} ?>><span class="brown-block" title="<?php echo __l('Success'); ?>"><?php echo $this->Html->link($this->Html->cInt($success,false).'<span>' .__l('Success'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => ConstWithdrawalStatus::Success), array('escape' => false));?></span> </li>
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Failed) { echo 'class="active"';} ?>><span class="lightblue-block" title="<?php echo __l('Failed'); ?>"><?php echo $this->Html->link($this->Html->cInt($failed,false).'<span>' .__l('Failed'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => ConstWithdrawalStatus::Failed), array('escape' => false));?></span> </li>
	       <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] == 'all') { echo 'class="active"';} ?>><span class="gmail-block" title="<?php echo __l('All'); ?>"><?php echo $this->Html->link($this->Html->cInt($approved + $pending + $rejected + $success + $failed,false).'<span>' .__l('All'). '</span>', array('controller'=>'user_cash_withdrawals','action'=>'index','filter_id' => 'all'), array('escape' => false));?></span> </li>
     </ul>
    </div>

    <div>
		<?php if($this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Approved): ?>
			<div class="content-info">		
				<?php echo __l('Following withdrawal request has been submitted to payment gateway API, These are waiting for IPN from the payment gateway API. Either it will move to Success or Failed'); ?>
			</div>
		<?php endif; ?>
	<div class="clearfix list-content-block">
		<h5><?php echo __l('Transfer Account: '); ?></h5>
		<ul class="list clearfix">
		<?php $class = ( !isset($this->request->params['named']['account_id']) || $this->request->params['named']['account_id'] == 'all' ) ? 'active' : null; ?>
		<li class="<?php echo $class ?>"><div class="js-pagination"><?php echo $this->Html->link(__l('All'), array('action' => 'index', 'filter_id' => $this->request->params['named']['filter_id'], 'account_id' => 'all'), array('title' => __l('All')));?></div></li>
		<?php foreach($paymentGateways as $paymentGateway): ?>
			<?php $class = (isset($this->request->params['named']['account_id']) && $this->request->params['named']['account_id'] == $paymentGateway['PaymentGateway']['id'] ) ? 'active' : null; ?>
			<li class="<?php echo $class ?>"><div class="js-pagination"><?php echo $this->Html->link($this->Html->cText($paymentGateway['PaymentGateway']['display_name'], false), array('action' => 'index', 'filter_id' => $this->request->params['named']['filter_id'], 'account_id' => $paymentGateway['PaymentGateway']['id']), array('title' => $this->Html->cText($paymentGateway['PaymentGateway']['display_name'], false)));?></div></li>
		<?php endforeach; ?>
	</ul>
	</div>
    <div>
       <?php echo $this->element('paging_counter');?>
    </div>
    <?php echo $this->Form->create('UserCashWithdrawal' , array('class' => 'normal','action' => 'update')); ?> <?php echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url)); ?>
    <table class="list">
        <tr>
    <?php if(isset($this->request->params['named']['filter_id']) && ($this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Pending)):?>
            <th></th>
			<?php endif;?>
		<th class="actions"><?php echo __l('Actions'); ?></th>
		
            <th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('User'),'User.username');?></div></th>
            <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Amount'), 'UserCashWithdrawal.amount').' ('.Configure::read('site.currency').')';?> </div></th>
            <?php if(empty($this->request->params['named']['filter_id'])) { ?>
                <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Status'),'WithdrawalStatus.name');?></div></th>
            <?php } ?>
        </tr>
    <?php
    if (!empty($userCashWithdrawals)):
    
    $i = 0;
    foreach ($userCashWithdrawals as $userCashWithdrawal):
        $class = null;
        if ($i++ % 2 == 0) {
            $class = ' class="altrow"';
        }
    ?>
        <tr<?php echo $class;?>>
		    <?php if(isset($this->request->params['named']['filter_id']) && ($this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Pending)):?>
			 <td class="select">
		    <?php echo $this->Form->input('UserCashWithdrawal.'.$userCashWithdrawal['UserCashWithdrawal']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$userCashWithdrawal['UserCashWithdrawal']['id'], 'label' => false, 'class' => 'js-checkbox-list ' )); ?>
			</td>
			<?php endif;?>
			<td>
			 <div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
							<li><?php echo $this->Html->link(__l('Delete'), array('action' => 'delete', $userCashWithdrawal['UserCashWithdrawal']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></li>
                   		 </ul>
						 <?php if($this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Approved): ?>
						         <ul class="action-link clearfix">
							<li class="round-5 withdrawal-status-5"><?php echo $this->Html->link(__l('Move to success'), array('action' => 'move_to', $userCashWithdrawal['UserCashWithdrawal']['id'], 'type' => 'success'), array('class' => 'move-to-success', 'title' => __l('Move to success')));?></li>
						<li class="round-5 withdrawal-status-4"><?php echo $this->Html->link(__l('Move to failed'), array('action' => 'move_to', $userCashWithdrawal['UserCashWithdrawal']['id'], 'type' => 'failed'), array('class' => 'move-to-failed', 'title' => __l('Move to failed')));?></li>
						<?php endif;?>
                   		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>


               
			
			



<!--<div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
							<li class="round-5 withdrawal-status-5"><?php echo $this->Html->link(__l('Move to success'), array('action' => 'move_to', $userCashWithdrawal['UserCashWithdrawal']['id'], 'type' => 'success'), array('class' => 'move-to-success', 'title' => __l('Move to success')));?></li>
						<li class="round-5 withdrawal-status-4"><?php echo $this->Html->link(__l('Move to failed'), array('action' => 'move_to', $userCashWithdrawal['UserCashWithdrawal']['id'], 'type' => 'failed'), array('class' => 'move-to-failed', 'title' => __l('Move to failed')));?></li>
                   		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>-->
         </td>
			<?php //endif;?>
            <td class="dl">
   
            <?php
			  foreach($userCashWithdrawal['User']['MoneyTransferAccount'] as $moneyTransferAccount):
				if(!empty($moneyTransferAccount['PaymentGateway'])):?>
					<span class="paypal"><?php echo $this->Html->cText($moneyTransferAccount['PaymentGateway']['display_name']);?></span>
			<?php
				endif;
			  endforeach;
			?>
	
			<?php echo $this->Html->showImage('UserAvatar', $userCashWithdrawal['User']['UserAvatar'], array('dimension' => 'micro_thumb', 'alt' => sprintf(__l('[Image: %s]'), $this->Html->cText($userCashWithdrawal['User']['username'], false)), 'title' => $this->Html->cText($userCashWithdrawal['User']['username'], false)));?>
            <?php echo $this->Html->link($this->Html->cText($userCashWithdrawal['User']['username']), array('controller'=> 'users', 'action'=>'view', $userCashWithdrawal['User']['username'],'admin' => false), array('title'=>$this->Html->cText($userCashWithdrawal['User']['username'],false),'escape' => false));?>
            </td>
			
			</td>
			<td><?php echo $this->Html->cCurrency($userCashWithdrawal['UserCashWithdrawal']['amount']);?></td>
            <?php if(empty($this->request->params['named']['filter_id'])) { ?>
                <td><?php echo $this->Html->cText($userCashWithdrawal['WithdrawalStatus']['name']);?></td>
            <?php } ?>
        </tr>
    <?php
        endforeach;
    else:
    ?>
        <tr>
            <td colspan="8" class="notice"><?php echo __l('No records available');?></td>
        </tr>
    <?php
    endif;
    ?>
    </table>		
    <?php
    if (!empty($userCashWithdrawals)) {
        ?>
		<?php if(isset($this->request->params['named']['filter_id']) && ($this->request->params['named']['filter_id'] == ConstWithdrawalStatus::Pending)):?>
	<div class="clearfix">	
		<div class="selection-block grid_left">
				<?php echo __l('Select:'); ?>
				<?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all', 'title' => __l('All'))); ?>
				<?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none', 'title' => __l('None'))); ?>
		</div>
			<div class="admin-checkbox-button"><?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --'))); ?></div>
		</div>
		<div class="hide"> <?php echo $this->Form->submit('Submit');  ?> </div>
      <?php endif; ?>
            <div class="js-pagination grid_right">
                <?php echo $this->element('paging_links'); ?>
            </div>
        <?php
    }
    ?>
      <?php echo $this->Form->end(); ?>
    </div>
